package com.nf.health.app.activity.manage_health;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.nf.health.app.Constants;
import com.nf.health.app.R;
import com.nf.health.app.activity.global.BaseActivity;
import com.nf.health.app.activity.my.MyShopStoreActivity;
import com.nf.health.app.utils.TextUtilTools;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 课题报名 未报名和未购买设备的界面
 * @author changpeng
 */
public class KetiSignUpActivity extends BaseActivity {

    @Bind(R.id.tv_no_device)
    TextView mTvNoDevice;
    @Bind(R.id.btn_sign_up)
    Button mBtnSignUp;
    @Bind(R.id.titlebar_title_tv)
    TextView mTitlebarTitleTv;

    private int mState;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitleBar(R.layout.titlebar_base);
        setContent(R.layout.activity_keti_sign_up);
        ButterKnife.bind(this);
        initView();
        initListener();
    }

    private void initView() {
        mTitlebarTitleTv.setText("健康中国·治未病健康工程");
        mState = getIntent().getIntExtra(Constants.KETI_STATE,100);
        if(mState == 3){
            String htmlText = "还没有监测设备？<font color = '#FD9854'><u>去商城看看>></u></font>";
            TextUtilTools.setTextFromHtml(mTvNoDevice,htmlText);
            mTvNoDevice.setVisibility(View.VISIBLE);
            mBtnSignUp.setVisibility(View.INVISIBLE);
        }else if(mState == 1){
            mTvNoDevice.setVisibility(View.INVISIBLE);
            mBtnSignUp.setVisibility(View.VISIBLE);
        }else{
            showToast("数据错误");
        }
    }

    private void initListener() {
        mTvNoDevice.setOnClickListener(this);
        mBtnSignUp.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()){
            case R.id.tv_no_device://跳转到商城
                startActivity(new Intent(this,MyShopStoreActivity.class));
                finish();
                break;
            case R.id.btn_sign_up://跳转到报名页面
                startActivity(new Intent(this,PreventionChronicActivity.class));
                finish();
                break;
        }
    }
}
